//
//  ParametersControl.cpp
//  Cryptarithmetic
//
//  Created by Derivery Guillaume on 4/23/13.
//  Copyright (c) 2013 Derivery Guillaume. All rights reserved.
//

#include "ParametersControl.h"

ParametersControl::ParametersControl()
{
}

bool ParametersControl::checkParameters(std::vector<std::string> &av)
{
    if (av.size() < 3)
    {
        std::cerr << "Bad parameters: Usage " << av[0]<< " fact1 fact2 restult" << std::endl;
        return false;
    }
    for (int i = 0; i < av.size(); i++)
    {
        std::string temp = av[i];
        for (int j = 0; j < temp.size(); j++)
        {
            if ((temp[j] <= 'a' && temp[j] >= 'z') ||
                (temp[j] <= 'A' && temp[j] >= 'Z'))
            {
                std::cerr << "Bad parameters: Parameter " << i << " is not a word!" << std::endl;
                this->parameters_.clear();
                return false;
            }
        }
        this->parameters_.push_back(av[i]);
    }
    return true;
}
void ParametersControl::clear()
{
    this->parameters_.clear();
}

std::vector<std::string> const &ParametersControl::getParameters() const
{
    return this->parameters_;
}


ParametersControl::~ParametersControl()
{
    this->parameters_.clear();
}
